package com.life.xxx.util;

/**
 * 响应状态码枚举
 */
public enum ResultCode {

    SUCCESS("200", "成功"),
    ERROR("500", "系统异常"),

    // 参数相关
    INVALID_PARAM("10001", "请求参数无效"),
    MISSING_PARAM("10002", "缺少必要参数"),

    // 用户相关
    UNAUTHORIZED("401", "未登录或登录已过期"),
    FORBIDDEN("403", "权限不足，禁止访问"),
    USER_NOT_FOUND("40401", "用户不存在"),
    USER_LOCKED("40402", "账户已被锁定"),

    // 认证相关
    LOGIN_FAIL("40101", "用户名或密码错误"),
    TOKEN_EXPIRED("40102", "登录凭证已过期"),
    TOKEN_INVALID("40103", "无效的登录凭证"),

    // 业务相关
    RECORD_NOT_FOUND("40403", "记录不存在"),
    DUPLICATE_DATA("409", "数据已存在，操作冲突"),
    BUSINESS_ERROR("50001", "业务处理失败"),
    SERVICE_UNAVAILABLE("503", "服务暂时不可用"),

    // 限流/降级
    REQUEST_LIMIT("429", "请求过于频繁，请稍后再试"),
    DEGRADED("50301", "服务已降级，请稍后重试");

    private final String code;
    private final String msg;

    ResultCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
